using UnityEngine;

namespace RedPoint
{
    public abstract class RedPointBase : MonoBehaviour
    {
        int count;
        protected int Count
        {
            get
            {
                return count;
            }
            private set
            {
                count = value;
                OnCountChange(count);
            }
        }
        protected virtual void Start()
        {
            string key = Key();
            Count = RedPointManager.Instance.GetCount(key);
            RedPointManager.Instance.AddListener(key, ListenCountChange);
        }
        protected void ListenCountChange(int count)
        {
            Count = count;
        }
        protected virtual void OnCountChange(int count)
        {

        }
        protected abstract string Key();

    }
}